Skip to main content
POST
/
v1
/
flux-2-pro
Generate or edit an image with FLUX.2 [pro]
curl --request POST \
  --url https://api.bfl.ai/v1/flux-2-pro \
  --header 'Content-Type: application/json' \
  --header 'x-key: <api-key>' \
  --data '
{
  "prompt": "ein fantastisches bild",
  "disable_pup": false,
  "input_image": "<string>",
  "input_image_2": "<string>",
  "input_image_3": "<string>",
  "input_image_4": "<string>",
  "input_image_5": "<string>",
  "input_image_6": "<string>",
  "input_image_7": "<string>",
  "input_image_8": "<string>",
  "seed": 42,
  "width": 0,
  "height": 0,
  "safety_tolerance": 2,
  "output_format": "jpeg",
  "webhook_url": "<string>",
  "webhook_secret": "<string>"
}
'
import requests

url = "https://api.bfl.ai/v1/flux-2-pro"

payload = {
    "prompt": "ein fantastisches bild",
    "disable_pup": False,
    "input_image": "<string>",
    "input_image_2": "<string>",
    "input_image_3": "<string>",
    "input_image_4": "<string>",
    "input_image_5": "<string>",
    "input_image_6": "<string>",
    "input_image_7": "<string>",
    "input_image_8": "<string>",
    "seed": 42,
    "width": 0,
    "height": 0,
    "safety_tolerance": 2,
    "output_format": "jpeg",
    "webhook_url": "<string>",
    "webhook_secret": "<string>"
}
headers = {
    "x-key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'x-key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    prompt: 'ein fantastisches bild',
    disable_pup: false,
    input_image: '<string>',
    input_image_2: '<string>',
    input_image_3: '<string>',
    input_image_4: '<string>',
    input_image_5: '<string>',
    input_image_6: '<string>',
    input_image_7: '<string>',
    input_image_8: '<string>',
    seed: 42,
    width: 0,
    height: 0,
    safety_tolerance: 2,
    output_format: 'jpeg',
    webhook_url: '<string>',
    webhook_secret: '<string>'
  })
};

fetch('https://api.bfl.ai/v1/flux-2-pro', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.bfl.ai/v1/flux-2-pro",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'prompt' => 'ein fantastisches bild',
    'disable_pup' => false,
    'input_image' => '<string>',
    'input_image_2' => '<string>',
    'input_image_3' => '<string>',
    'input_image_4' => '<string>',
    'input_image_5' => '<string>',
    'input_image_6' => '<string>',
    'input_image_7' => '<string>',
    'input_image_8' => '<string>',
    'seed' => 42,
    'width' => 0,
    'height' => 0,
    'safety_tolerance' => 2,
    'output_format' => 'jpeg',
    'webhook_url' => '<string>',
    'webhook_secret' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "x-key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.bfl.ai/v1/flux-2-pro"

	payload := strings.NewReader("{\n  \"prompt\": \"ein fantastisches bild\",\n  \"disable_pup\": false,\n  \"input_image\": \"<string>\",\n  \"input_image_2\": \"<string>\",\n  \"input_image_3\": \"<string>\",\n  \"input_image_4\": \"<string>\",\n  \"input_image_5\": \"<string>\",\n  \"input_image_6\": \"<string>\",\n  \"input_image_7\": \"<string>\",\n  \"input_image_8\": \"<string>\",\n  \"seed\": 42,\n  \"width\": 0,\n  \"height\": 0,\n  \"safety_tolerance\": 2,\n  \"output_format\": \"jpeg\",\n  \"webhook_url\": \"<string>\",\n  \"webhook_secret\": \"<string>\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-key", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.bfl.ai/v1/flux-2-pro")
  .header("x-key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"prompt\": \"ein fantastisches bild\",\n  \"disable_pup\": false,\n  \"input_image\": \"<string>\",\n  \"input_image_2\": \"<string>\",\n  \"input_image_3\": \"<string>\",\n  \"input_image_4\": \"<string>\",\n  \"input_image_5\": \"<string>\",\n  \"input_image_6\": \"<string>\",\n  \"input_image_7\": \"<string>\",\n  \"input_image_8\": \"<string>\",\n  \"seed\": 42,\n  \"width\": 0,\n  \"height\": 0,\n  \"safety_tolerance\": 2,\n  \"output_format\": \"jpeg\",\n  \"webhook_url\": \"<string>\",\n  \"webhook_secret\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.bfl.ai/v1/flux-2-pro")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"prompt\": \"ein fantastisches bild\",\n  \"disable_pup\": false,\n  \"input_image\": \"<string>\",\n  \"input_image_2\": \"<string>\",\n  \"input_image_3\": \"<string>\",\n  \"input_image_4\": \"<string>\",\n  \"input_image_5\": \"<string>\",\n  \"input_image_6\": \"<string>\",\n  \"input_image_7\": \"<string>\",\n  \"input_image_8\": \"<string>\",\n  \"seed\": 42,\n  \"width\": 0,\n  \"height\": 0,\n  \"safety_tolerance\": 2,\n  \"output_format\": \"jpeg\",\n  \"webhook_url\": \"<string>\",\n  \"webhook_secret\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "polling_url": "<string>",
  "cost": 123,
  "input_mp": 123,
  "output_mp": 123
}
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}
The recommended default model for most generation and editing. New to FLUX.2? See which model to use.

Authorizations

x-key
string
header
required

Body

application/json
prompt
string
required

Text prompt for image generation.

Example:

"ein fantastisches bild"

disable_pup
boolean
default:false

Disable automatic prompt upsampling for this request. FLUX.2 [pro] and [max] apply prompt upsampling by default; set this to true to generate from your prompt exactly as written.

input_image
string | null

Path to the input image.

input_image_2
string | null

Path to the second input image.

input_image_3
string | null

Path to the third input image.

input_image_4
string | null

Path to the fourth input image.

input_image_5
string | null

Path to the fifth input image.

input_image_6
string | null

Path to the sixth input image.

input_image_7
string | null

Path to the seventh input image.

input_image_8
string | null

Path to the eighth input image.

seed
integer | null

Optional seed for reproducibility.

Example:

42

width
integer | null
default:0

Width of the image

Required range: x >= 64
height
integer | null
default:0

Height of the image

Required range: x >= 64
safety_tolerance
integer
default:2

Tolerance level for input and output moderation. Between 0 and 5, 0 being most strict, 5 being least strict. If you wish to increase the safety_tolerance beyond these levels please reach out to the team.

Required range: 0 <= x <= 5
output_format
enum<string> | null
default:jpeg
Available options:
jpeg,
png,
webp
webhook_url
string<uri> | null

URL to receive webhook notifications

Required string length: 1 - 2083
webhook_secret
string | null

Optional secret for webhook signature verification

Response

Successful Response

id
string
required
polling_url
string
required
cost
number | null

Cost in credits for this request

input_mp
number | null

Input megapixels (2 decimal places)

output_mp
number | null

Output megapixels (2 decimal places)